/*
FieldEvent.cpp
Field Event Implementation file 
Zach Agudelo, Andi Cescolini, Sam Tarin

handles every possible event
every function is not used, but all are included for future features
Allows for all types of SDL events to be handled and given functionality
Field inherits from FeildEvent
*/


#include "FieldEvent.h"
 
FieldEvent::FieldEvent() {

}
 
FieldEvent::~FieldEvent() {
    //Do nothing
}
//called on any user interaction filters all types of events
void FieldEvent::OnEvent(SDL_Event* Event) { 
	 //handle all posible events(only use a couple are used, but all are include for completeness)
    switch(Event->type) {
        case SDL_ACTIVEEVENT: {
            switch(Event->active.state) {
                case SDL_APPMOUSEFOCUS: {
                    if ( Event->active.gain )    OnMouseFocus();
                    else                OnMouseBlur();
 
                    break;
                }
                case SDL_APPINPUTFOCUS: {
                    if ( Event->active.gain )    OnInputFocus();
                    else                OnInputBlur();
 
                    break;
                }
                case SDL_APPACTIVE:    {
                    if ( Event->active.gain )    OnRestore();
                    else                OnMinimize();
 
                    break;
                }
            }
            break;
        }
 		  //Key is pressed (store the key code)	
        case SDL_KEYDOWN: {
            OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
            break;
        }
        //key is released
        case SDL_KEYUP: {
            OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
            break;
        }
 	     //mouse events
        case SDL_MOUSEMOTION: {
            OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
            break;
        }
 
        case SDL_MOUSEBUTTONDOWN: {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonDown(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_MOUSEBUTTONUP:    {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonUp(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 		  //exit SDL(clcik the x in the corner of screen)
        case SDL_QUIT: {
            OnExit();
            break;
        }
 
        case SDL_SYSWMEVENT: {
            //Ignore
            break;
        }
 
        case SDL_VIDEORESIZE: {
            OnResize(Event->resize.w,Event->resize.h);
            break;
        }
 
        case SDL_VIDEOEXPOSE: {
            OnExpose();
            break;
        }
 
        default: {
            OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
            break;
        }
    }
}
//ALL FUNCTIONS BELOW IF USED ARE REDEFINED IN IHERITED CLASSES (Field)
void FieldEvent::OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnInputFocus() {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnInputBlur() {
    //Virtual redefined elsewhere
}

void FieldEvent::OnMouseFocus() {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnMouseBlur() {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnMouseMove(int mX, int mY, int relX, int relY, bool Left,bool Right,bool Middle) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnMouseWheel(bool Up, bool Down) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnLButtonDown(int mX, int mY) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnLButtonUp(int mX, int mY) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnRButtonDown(int mX, int mY) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnRButtonUp(int mX, int mY) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnMButtonDown(int mX, int mY) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnMButtonUp(int mX, int mY) {
    //Virtual redefined elsewhere
}

void FieldEvent::OnMinimize() {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnRestore() {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnResize(int w,int h) {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnExpose() {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnExit() {
    //Virtual redefined elsewhere
}
 
void FieldEvent::OnUser(Uint8 type, int code, void* data1, void* data2) {
    //Virtual redefined elsewhere
}

